//
//  DestinationView.m
//  A段项目
//
//  Created by 刘言松 on 15/10/12.
//  Copyright (c) 2015年 刘言松. All rights reserved.
//

#import "DestinationView.h"

@interface DestinationView ()<UIScrollViewDelegate>


@end

@implementation DestinationView

- (void)dealloc {

    
}



-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        [self addSubviews];
    }
    
    return self;
}

- (void)addSubviews{
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    
    flowLayout.itemSize = CGSizeMake(WIDTH * 0.44 , WIDTH * 0.44);
    
    flowLayout.minimumLineSpacing = 5;
    flowLayout.minimumInteritemSpacing = 5;
    flowLayout.headerReferenceSize = CGSizeMake(WIDTH, HEIGHT * 0.07);
    
    flowLayout.sectionInset = UIEdgeInsetsMake(0,WIDTH * 0.05, 0, WIDTH * 0.05);
    
    self.myCollectionView = [[BaseCollectionView alloc] initWithFrame: CGRectMake(0, 0, WIDTH, HEIGHT) collectionViewLayout:flowLayout];
     
    self.myCollectionView.contentInset = UIEdgeInsetsMake(HEIGHT * 0.3, 0, 0, 0);
   
   
 
    [self addSubview:self.myCollectionView];
    
    self.headImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, - HEIGHT * 0.3, WIDTH, HEIGHT * 0.3)];
    self.headImage.contentMode = UIViewContentModeScaleAspectFill;
    self.headImage.layer.masksToBounds = YES;
    [self.myCollectionView addSubview:self.headImage];
 
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = self.headImage.frame;
    [btn addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.myCollectionView addSubview:btn];
    
    UILabel *hottest_sites = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, WIDTH * 0.4, HEIGHT * 0.08)];
    hottest_sites.center = self.center;
    hottest_sites.y = self.headImage.y + self.headImage.height;
    hottest_sites.text = @"推荐地点";
    hottest_sites.textAlignment = NSTextAlignmentCenter;
    [self.myCollectionView addSubview:hottest_sites];
 
}

- (void)clickAction:(UIButton *)btn{
  
    [_delegate push_album];
}




@end
